package j02zuoye;

import java.io.*;

public class J1FileTest {
    public static void main(String[] args) throws Exception {
        File f = new File("_0906/src/j02zuoye/file/JavaSE");
        if(!f.exists()){
            //目录不存在,创建目录
            f.mkdirs();
        }
        //目录肯定有
        f = new File("_0906/src/j02zuoye/file/JavaSE/IO.txt");
        //判断文件是否存在
        if(f.exists()){
            //文件存在，读取
            BufferedReader fs = new BufferedReader(
                    new FileReader(f)
            );
            while (true){
                int num = fs.read();
                if(num==-1)return;
                System.out.print((char) num);
            }
        }else{
            //文件不存在，创建并写入内容
            BufferedWriter fs = new BufferedWriter(
                    new FileWriter(f)
            );
            fs.write("IO是InputStream和OutputStream!");
            fs.close();
        }

    }
}
